﻿@{    
    string content = string.Empty;
    string html = Convert.ToString(Model.Html);
    if (!string.IsNullOrWhiteSpace(html))
    {
        try
        {
            content = RazorEngine.Razor.Parse(html, new { Id = Model.ContentPart.Id, Text = Model.ContentPart.Text, ContentPart = Model.ContentPart, Html = Model.Html });            
        }
        catch (RazorEngine.Templating.TemplateCompilationException tcex)
        {
            System.Text.StringBuilder errorStringBuilder = new System.Text.StringBuilder();
            errorStringBuilder.AppendLine(tcex.Message);
            errorStringBuilder.AppendLine(string.Format("Errors ({0}):", tcex.Errors.Count));
            foreach (var error in tcex.Errors)
            {
                errorStringBuilder.AppendLine(error.ToString());
            }
            content = errorStringBuilder.ToString();
        }
        catch (Exception ex)
        {
            content = ex.ToString();
        }
    }
}
@Html.Raw(content)